package com.tech.utils;

import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateScalarModel;

import java.util.List;

/**
 * Created by zouyao on 2023/06/02
 */
@FunctionalInterface
public interface FunctionRegister extends TemplateMethodModelEx {

    @Override
    default Object exec(List arguments) throws TemplateModelException {
        if (arguments.size() != 1) {
            throw new TemplateModelException("Wrong arguments");
        }
        TemplateScalarModel arg = (TemplateScalarModel) arguments.get(0);
        String str = arg.getAsString();
        return process(str);
    }

    Object process(String str);


}
